<template>
  <el-dialog :title="title"
             :visible.sync="visible"
             v-loading="loading"
             :before-close="modalClose"
             :close-on-click-modal="false"
             :close-on-press-escape="false"
             width="80%"
             append-to-body>
    <element-table :columns="columns"
                   class="mt-20"
                   :data="tableData"
                   v-loading="loading"
                   pager
                   :pageTotal="pageTotal"
                   :pageIndex="pageIndex"
                   :pageSize="pageSize"
                   @handleChangePage="handleChangePage">
      <template v-slot:status="{row}">
        <el-tag type="danger"
                v-if="row.status === 0">未开始</el-tag>
        <el-tag type="success"
                v-if="row.status === 1">进行中</el-tag>
        <el-tag type="danger"
                v-if="row.status === 2">已结束</el-tag>
      </template>

    </element-table>

  </el-dialog>
</template>
<script>
  import elementTable from '@/base/ElementTable'
  export default {
    name: 'statisticsDialog', // 统计查看
    props: {
      dataObj: {
        type: Object,
        default: {}
      },
      visible: {
        type: Boolean,
        default: false
      },
    },
    data () {
      return {
        title: '统计查看',
        loading: false,
        columns: [
          {
            label: '分店名称',
            prop: 'companyName',
          },
          {
            label: '店长姓名',
            prop: 'name',
          },
          {
            label: '联系方式',
            prop: 'phone',
          },
          {
            label: '详细地址',
            prop: 'address',
          },
          {
            label: '医生解读次数',
            prop: 'interests',
          },
          {
            label: '医生咨询次数',
            prop: 'companyName',
          },
          {
            label: '检测人次',
            prop: 'createTime'
          },
          {
            label: '小票打印次数',
            prop: 'startTime'
          },
          {
            label: '学习完成情况',
            prop: 'endTime'
          },
          {
            label: '完成一次购买客户数',
            prop: 'status',
            align: 'center'
          },
          {
            label: '完成两次购买客户数',
            prop: 'status',
            align: 'center'
          }

        ],
        tableData: [],
        pageTotal: 0,
        pageIndex: 0,
        pageSize: 10,
      }
    },
    methods: {
      modalClose () {
        this.$emit('update:visible', false); // 直接修改父组件的属性
      },
      getList () {
        this.tableData = [
          { companyName: '检测项目名称', name: '关联合并症', screeningItems: '推荐健康筛查项目', item: 13402870536, createTime: 1615245781245, createTime: 1615245781245, startTime: 1615245781245, endTime: 1615245781245, status: 0 },
          { name: '检测项目名称', complications: '关联合并症', screeningItems: '推荐健康筛查项目', item: 13402870536, createTime: 1615245781245, createTime: 1615245781245, startTime: 1615245781245, endTime: 1615245781245, status: 1 },
          { name: '检测项目名称', complications: '关联合并症', screeningItems: '推荐健康筛查项目', item: 13402870536, createTime: 1615245781245, createTime: 1615245781245, startTime: 1615245781245, endTime: 1615245781245, status: 2 },
        ];
        this.pageTotal = this.tableData.length;
      },
      // 分页
      handleChangePage (page) {
        this.pageIndex = page;
        this.getList();
      },

    },
    created () {
      this.getList();
    },
    components: {
      'element-table': elementTable,
    }
  }
</script>
<style scoped lang="scss">
</style>